﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sync_IniControler
{
    class IniSection
    {
        #region Attributes

        private List<string> _comments;
        private string _nameSection;
        private Dictionary<string, string> _params;

        #endregion

        #region Methods

        public IniSection()
        {
            _comments = new List<string>();
            _nameSection = "";
            _params = new Dictionary<string, string>();
        }

        public string getValue(string key)
        {
            return  (_params.ContainsKey(key)) ? _params[key] : null;
        }

        public string getKey(string value)
        {
            if (!_params.ContainsValue(value))
                return null;
            for (int it = 0; it < _params.Count; it++)
            {
                if (_params.Values.ElementAt<string>(it) == value)
                    return _params.Keys.ElementAt<string>(it);
            }
            return null;
        }

        #endregion

        #region Get & Set

        public List<string> Comments
        {
            get { return _comments; }
            set { _comments = value; }
        }

        public string Section
        {
            get { return _nameSection; }
            set { _nameSection = value; }
        }

        public Dictionary<string, string> Params
        {
            get { return _params; }
            set { _params = value; }
        }

        #endregion
    }
}
